// Copyright (C) 2022-2022 wuchengwen. All Rights Reserved.
// Description:
// Author : wuchengwen <wuchw@foxmail.com>
// Date :2022-08-28

#include <iostream>

using namespace std;
// https://en.cppreference.com/w/cpp/language/attributes/nodiscard
struct [[nodiscard]] ErrorInfo { /*...*/
};
ErrorInfo TestFunc()
{ /*...*/
    return {};
}

void Test()
{
    TestFunc(); // compiler may warn on discarding a nodiscard value
}

ErrorInfo &Foo()
{
    static ErrorInfo e; /*...*/
    return e;
}
void F1()
{
    Foo(); // nodiscard type is not returned by value, no warning
}
// nodiscard( string-literal ) (since C++20):
[[nodiscard("PURE FUN")]] int strategic_value(int x, int y)
{
    return x ^ y;
}

int main()
{
    strategic_value(4, 2);          // compiler may warn on discarding a nodiscard value
    auto z = strategic_value(0, 0); // ok: return value is not discarded
    return z;
}